package com.luedinski.servlets;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.luedinski.objects.Net;
import com.luedinski.objects.Route;
import com.luedinski.objects.Station;
import com.luedinski.objects.Time;

/**
 * Servlet zur einfacheren Erzeugung von Zugverbindungen.
 */
@WebServlet("/Test")
public class Test extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public Test() {
		super();
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		
		Net net = new Net();

		ArrayList<Station> routeStations = new ArrayList<Station>();
		

		routeStations.add(Station.fromSql(4333));
		routeStations.add(Station.fromSql(2713));
		routeStations.add(Station.fromSql(925));
		routeStations.add(Station.fromSql(570));
		routeStations.add(Station.fromSql(1658));
		routeStations.add(Station.fromSql(10831));
		routeStations.add(Station.fromSql(128));
		

		System.out.println(routeStations.toString());
		Route routeA = new Route("ICE 173", 180, routeStations, net);
		routeA.generateTimetable(new Time(6, 30), new Time(21, 0), 120);
		// routeA.printRoute();
		System.out.println("Net :"+net.getNet().toString());
		//Route r = Route.fromSql(13, net);
		//System.out.println(r.toString());
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
